package com.example.personal.aiagent.common.util;

import com.example.personal.aiagent.common.constant.ErrorCode;
import com.example.personal.aiagent.common.exception.CustomServiceException;

import java.util.Objects;

/**
 * 请求参数工具类
 */
public class RequestParamUtil {

    /**
     * 字符串转Integer
     *
     * @param str 字符串
     * @return Integer
     */
    public static Integer strToInt(String str) {
        try {
            return Objects.equals(str, "null") ? null : Integer.parseInt(str);
        } catch (NumberFormatException formatException) {
            throw new CustomServiceException(" str to int error", formatException, ErrorCode.PARAM_ERROR);
        }
    }
}
